<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <ul class="testUL">
        <li>index=0</li>
        <li>index=1</li>
        <li>index=2</li>
        <li>index=3</li>
    </ul>
</body>
</html>
<script>
    var nodes=document.getElementsByTagName("li");
    for(i=0;i<nodes.length;i+=1){
        nodes[i].onclick=(function(i){
            return function(){
                console.log(i);
            }
        })(i);
    }
    function say667(){
        var num =666;
        var sayAlert =function(){
            alert(num);
        }
        num++;
        return sayAlert;
    }
    var sayAlert=say667();
    sayAlert()
</script>